package action.model;

import service.model.AdminService;

import entity.Admin;
import action.BaseAction;


@SuppressWarnings("serial")
public class AdminAction extends BaseAction{

	private Admin admin;
	private AdminService adminService;
	private static final String HQL="from Admin where username=:username and password=:password";
	
	
	public String login() throws Exception{
		String[] values={admin.getUsername(),admin.getPassword()};
		Admin admin=adminService.login(HQL, values);
		if (admin!=null) {
			getSession().put("admin", admin);
			return "login";
		} else {
			getRequest().put("message", "ERROR...");
			return "login_input";
		}
	}

	
	
	public Admin getAdmin() {
		return admin;
	}
	public void setAdmin(Admin admin) {
		this.admin = admin;
	}
	public AdminService getAdminService() {
		return adminService;
	}
	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}


}
